package com.lagou.mr.nsort;


import org.apache.hadoop.io.LongWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.io.Text;
import org.apache.hadoop.mapreduce.Mapper;

import java.io.IOException;

public class SortMapper extends Mapper<LongWritable, Text, NumberBean, NullWritable> {
    final NumberBean bean = new NumberBean();

    @Override
    protected void map(LongWritable key, Text value, Context context) throws IOException, InterruptedException {
        final String[] fields = value.toString().split("\t");
        bean.setValue(Long.parseLong(fields[0]));
        bean.setIndex(0L);
        context.write(bean, NullWritable.get());
    }
}
